package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.biz.domain.BizArea;
import com.ruoyi.biz.service.BizAreaService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 地区管理Controller
 *
 * @author tianl
 * @date 2024-12-19
 */
@RestController
@RequestMapping("/biz/bizArea" )
public class BizAreaController extends BaseController {
    @Autowired
    private BizAreaService bizAreaService;

    /**
     * 查询地区管理列表
     */
    @GetMapping("/list" )
    public AjaxResult list(BizArea bizArea) {
        List<BizArea> list = bizAreaService.list(bizArea);
        return success(list);
    }

    /**
     * 导出地区管理列表
     */
    @Log(title = "地区管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, BizArea bizArea) {
        List<BizArea> list = bizAreaService.list(bizArea);
        ExcelUtil<BizArea> util = new ExcelUtil<BizArea>(BizArea.class);
        util.exportExcel(response, list, "地区管理数据" );
    }

    /**
     * 获取地区管理详细信息
     */
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(bizAreaService.selectById(id));
    }

    /**
     * 新增地区管理
     */
    @Log(title = "地区管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizArea bizArea) {
        bizAreaService.beforeSave(bizArea);
        return AjaxResult.success();
    }

    /**
     * 修改地区管理
     */
    @Log(title = "地区管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizArea bizArea) {
        bizAreaService.beforeSave(bizArea);
        return AjaxResult.success();
    }

    /**
     * 删除地区管理
     */
    @Log(title = "地区管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(bizAreaService.deleteByIds(ids));
    }
}
